package com.demo.hbase;

import java.io.IOException;

import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;

import com.demo.hbase.utils.HBASEUtil;

public class HbaseDemo {
	
	private static HBASEUtil hbaseUti = new HBASEUtil("2181", "127.0.0.1", "hdfs://127.0.0.1:9000/users/hbase");

	public static void main(String[] args) throws IOException {
		printTable();
		hbaseUti.createTable("testTableB", "userId", "infos");
		printTable();
	}
	
	private static void printTable() throws IOException{
		System.out.println("==========printTable start============");
		TableName[] tableNames = hbaseUti.getHbaseConnection().getAdmin().listTableNames();
		HTableDescriptor[] htds = hbaseUti.getHbaseConnection().getAdmin().listTables();
		if(htds!=null){
			for(HTableDescriptor htd:htds){
				htd.getConfiguration();
			}
		}
		if(tableNames!=null){
			for(TableName tname:tableNames){
				System.out.println(tname);
			}
		}
		System.out.println("==========printTable end============");
	}

}
